<div id="content">
	<div class="row s_page_title">
		<sa-big-breadcrumbs [items]="['物料跟踪管理','基础信息维护','项目管理']" icon="fa-lg fa-fw fa fa-cubes" class="col-xs-12 col-sm-7 col-md-7 col-lg-4"></sa-big-breadcrumbs>
	</div>
	<sa-widgets-grid>
		<div class="s_table">
			<div sa-widget [editbutton]="false" color="darken" class="clearfix">
				<header><span class="widget-icon"> <i class="fa fa-table"></i> </span><h2>项目管理</h2></header>
				<div>
					<div class="widget-body no-padding">
						<div class="page-header clearfix s_table_opreation">
							<div class="left page-header-btn">
								<div class="top_module">
									<span class="module_text">所属厂区</span>
									<sa-company-tree companyTreeId="companyTree" (companySelected)="companySelected($event)"></sa-company-tree>                     
								</div>
								<button  type="button"  class="btn btn-primary" (click)="table_search()">查看</button>
								<button class="btn btn-primary" (click)="table_add(bomProjectModal)">新增</button>
								<button  type="button"  class="btn btn-primary" (click)="showImportModal(weightModal)">导入Excel文件</button>
							</div>
							<div class="right top-search" style="width:250px">
								<input type="text" [(ngModel)]="searchKey" (change)="table_search()" class="search-input" placeholder="项目名称,签约单位,联系人,地址">
								<span class="top-search-box">
							        <button class="top-search-btn" type="button" (click)="table_search()"> <i class="fa fa-search"></i></button>
							    </span>
							</div>
						</div>
						<div class="table_scroll">
							<table class="display dataTables responsive table table-striped table-bordered table-hover dataTable s_h5_table">
								<thead>
									<tr>
										<th>项目名称</th>
										<th>所属厂区</th>
										<th>项目经理</th>
										<th>签约单位</th>
										<th>联系人</th>
										<th>联系电话</th>
										<th>邮寄地址</th>
										<th>录入人</th>
										<th>录入时间</th>
										<th>编辑人</th>
										<th>编辑时间</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<tr *ngFor="let row of tableData" >
										<td>{{row.projectName}}</td>
										<td>{{row.companyName}}</td>
										<td>{{row.pmName}}</td>
										<td>{{row.signUnit}}</td>
										<td>{{row.linkMan}}</td>
										<td>{{row.linkPhone}}</td>
										<td>{{row.address}}</td>
										<td>{{row.enterMan}}</td>
										<td>{{row.enterTime}}</td>
										<td>{{row.editMan}}</td>
										<td>{{row.editTime}}</td>
										<td>
											<button type="button" (click)="multiplexRow(row,$event,bomProjectModal)">复用</button>
											<button type="button" (click)="editRow(row,$event,bomProjectModal)">编辑</button>
											<button type="button" (click)="delRow(row)">删除</button>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
						<div class="table-fix clearfix">
							<paginator [totalRecords]="totalCount"
						           [rows]="pageSize"
						           [currentPage]="curPage - 1"
						           (onPageChange)="paginate($event)">
							</paginator>
							<button type="button" class="btn default refresh_btn" (click)="refresh()"><i class="fa fa-refresh"></i></button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</sa-widgets-grid>
	<!--    弹窗-->
	<section bsModal #bomProjectModal="bs-modal" id="bomProjectModal" class="modal fade" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" >
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" (click)="modalClose(bomProjectModal)" aria-label="Close"><span aria-hidden="true">&times;</span></button>     
					<h4 class="modal-title"><span *ngIf="formType == 'new'">新增</span><span *ngIf="formType == 'updata'">编辑</span>项目</h4>
				</div>
				<form id="bomProjectFrom"  class="form-horizontal" role="form" novalidate="novalidate" [saBootstrapValidator]="validatorOptions">
					<div class="modal-body">
						<div class="row form-horizontal">
							<div class="form-group col-xs-12 s_fix_select2">
								<label class="control-label  col-xs-4 col-sm-2">项目名称<sup>*</sup></label>
								<div class="col-xs-10" >
									<input style="width:100%;" type="text" class="form-control" name="projectName" [(ngModel)]='bomProjectFrom.projectName'/>
								</div>
							</div>
							<div class="form-group col-xs-12 s_fix_select2">
								<label class="control-label  col-xs-4 col-sm-2">所属厂区<sup>*</sup></label>
								<div class="col-xs-10">
									<sa-company-tree wrap="html" companyTreeId="companyTree1" [Height]="32" [companyNameValue]="bomProjectFrom.companyName" [companyIdValue]="bomProjectFrom.companyId" (companySelected)="addCompanySelected($event)"></sa-company-tree>
								</div>
							</div>
							<div class="form-group col-xs-12 s_fix_select2">
								<label class="control-label  col-xs-4 col-sm-2">项目经理</label>
								<div class="col-xs-10 s_hover_box">
									<select class="form-control select2" id="pmSelect2" select2 name="pmSelect2" style="width: 100%">
										<option value=""></option>
									</select>
									<div class="s_del_icon" style="right:17px;top:9px;" (click)='delpmSelect()'>x</div>
								</div>
							</div>
							<div class="form-group col-xs-12 s_fix_select2">
								<label class="control-label col-xs-4 col-sm-2">签约单位<sup>*</sup></label>
								<div class="col-xs-10" >
									<input style="width:100%;"  class="form-control" name="signUnit" [(ngModel)]='bomProjectFrom.signUnit'/>
								</div>
							</div>
							<div class="form-group col-xs-12 s_fix_select2">
								<div class="col-xs-10" >
									<textarea style="margin-left: 10px;" rows="4" class="form-control" name="copyInfo" placeholder="粘贴地址信息，点击‘识别’自动拆分联系人，电话和地址。例如：某某某，13252452524，广东省深圳市南山区永和高分子研究大厦" [(ngModel)]='bomProjectFrom.copyInfo'></textarea>
								</div>
								<div class="col-xs-1">
									<button type="button"  class="btn btn-warning" style="min-width: 68px;display: block;" (click)="copyInfoClick()" >识别</button>
									<button type="button"  class="btn btn-link clearBtn" style="" (click)="clearInfo()">清空</button>
								</div>
							</div>
							<div class="form-group col-xs-12 s_fix_select2">
								<label class="control-label  col-xs-4 col-sm-2">联系人<sup>*</sup></label>
								<div class="col-xs-10" >
									<input style="width:100%;"  class="form-control" name="linkMan" [(ngModel)]='bomProjectFrom.linkMan'/>
								</div>
							</div>
							<div class="form-group col-xs-12 s_fix_select2">
								<label class="control-label  col-xs-4 col-sm-2">联系电话<sup>*</sup></label>
								<div class="col-xs-10" >
									<input style="width:100%;" class="form-control" name="linkPhone" [(ngModel)]='bomProjectFrom.linkPhone'/>
								</div>
							</div>

							<div class="form-group col-xs-12 s_fix_select2">
								<label class="control-label  col-xs-4 col-sm-2">邮寄地址<sup>*</sup></label>
								<div class="col-xs-10" >
									<input style="width:100%;"  class="form-control" name="address" [(ngModel)]='bomProjectFrom.address'/>
								</div>
							</div>
							
	                   	</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" (click)="modalClose(bomProjectModal)">取消</button>
						<button type="button" class="btn btn-primary" (click)="userControlSubmit(bomProjectModal)">确认</button>
					</div>
				</form>
			</div>
		</div>
	</section>
	<!--  弹窗end-->
	<!-- 导入弹框 -->
	<div bsModal #weightModal="bs-modal" id="weightModal" class="modal fade" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false"  >
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" (click)="cancelUp(weightModal)" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title">上传Excel文件</h4>
				</div>
				<div class="modal-body">

					<div class="row">
						<form class="form form-inline " role="form">
							<div class="row" style="margin-bottom: 24px;">
								<div class="form-group module_line">
									<button type="button" class="btn btn-primary" (click)="load_module()">下载模板</button>
									<span class="row" class="note">注：请先下载模板，采用模板编辑文件后上传</span>
								</div>
							</div>
							
							<div class="row">
								<!--<label class="control-label col-sm-1" for="imgFile" style="padding: 0;display: inline-block;line-height: 32px;">文件</label>-->
								<div class="col-sm-10" style="padding: 0;">
									<div class="clearfix module_line">
										<button type="button" class="btn btn-primary" style="width: 120px;">上传导入文件
											<input type="file" class="up" (change)="fileChange($event.target.files)" name="fileToUpload" (click)='clearFile()' [(ngModel)]='fileUp' type="file" placeholder='' />
										</button>
										<span class="row" class="note">注：格式excel</span>
									</div>
								</div>
							</div>
							<div *ngIf="fileToUpload">
								<label class="control-label col-sm-1"></label>
								<div>
									<ul>
										<li class="file_list">
											<i class="fa fa-file-text-o" style="margin-right: 12px;"></i>
											{{fileToUpload.name}}
											<i class="fa fa-check-circle green" style="margin-left: 60px;"></i>
										</li>
									</ul>
								</div>
							</div>
						</form>
					</div>

				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" (click)="cancelUp(weightModal)">取消</button>
					<button type="button" class="btn btn-primary" (click)="submitData(weightModal)">确认</button>
				</div>
			</div>
		</div>
	</div>
<!-- 导入弹框 结束 -->
</div>